package com.chuangyang.fixboxmaster.ui;

import android.os.Bundle;
import android.text.Html;
import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.Response;
import com.chuangyang.fixboxmaster.BuildConfig;
import com.chuangyang.fixboxmaster.R;
import com.chuangyang.fixboxmaster.bean.BaseInfo;
import com.chuangyang.fixboxmaster.bean.Message;
import com.chuangyang.fixboxmaster.service.FixBoxApi;
import com.chuangyang.fixboxmaster.service.GsonRequest;

import java.util.HashMap;


/**
 * Created by vanshu on 15/8/25 17:22.
 */
public class MessageDetailActivity extends BaseActivity {

    private TextView mTitle;
    private TextView mContent;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Message message = (Message) getIntent().getSerializableExtra("message");
        setContentView(R.layout.activity_message_detail);
        mTitle = (TextView) findViewById(R.id.message_title);
        mContent = (TextView) findViewById(R.id.message_content);
        mTitle.setText(message.title);

//        mContent.getSettings().setJavaScriptEnabled(true);
//        mContent.loadData(message.body, "text/html", "UTF-8");
        mContent.setText(Html.fromHtml(message.body));
        HashMap<String, String> param = new HashMap<>();
        param.put("msgId", "" + message.id);
        addRequest(new GsonRequest<>(FixBoxApi.READ_ONE_MESSAGE, param, BaseInfo.class, responseListener));

    }


    private Response.Listener<BaseInfo> responseListener = new Response.Listener<BaseInfo>() {
        @Override
        public void onResponse(BaseInfo response) {
            if (response.success == 1) {
                if (BuildConfig.DEBUG)
                    Toast.makeText(MessageDetailActivity.this, "读取成功", Toast.LENGTH_SHORT).show();
            }
        }
    };
}
